'use strict';
function compare(arr1,arr2){
  if(arr1<arr2){
    return -1;
  }
  else if(arr1>arr2){
    return 1;
  }
  else{
    return 0;
  }
}
function compute_chain_median(collection) {
  let result;
  collection=collection.split("->");
  collection=collection.map(function(x){
    return Number(x);
  });
  collection.sort(compare);
  if(collection.length%2==0){
     result=(collection[collection.length/2]+collection[collection.length/2-1])/2;
  }
  else{
    result=collection[(collection.length-1)/2];
  }
  console.log(result);
  return result;
}

module.exports = compute_chain_median;
compute_chain_median('1->4->6->2->3->10->9->8->11->20->19->30');